<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:permission="http://www.w3.org/1999/xhtml">
<head th:include="/common/head::commonHead('角色管理',~{::link},~{})">
    <link rel="stylesheet" th:href="@{/css/index.css}" media="all">
</head>
<body id="body-container">
<div class="layui-btn-group operateTable">
    <button permission:hasPermission="role::save" data-type="addRole" class="layui-btn layui-btn-sm layui-btn-primary">
        <i class="layui-icon layui-icon-add-circle-fine"></i> 新增
    </button>
    <button permission:hasPermission="role::delete" data-type="deleteBatchRole" class="layui-btn layui-btn-sm layui-btn-primary">
        <i class="layui-icon layui-icon-delete"></i> 批量删除
    </button>
</div>
<table class="layui-hide" id="data" lay-filter="role"></table>
<script type="text/html" id="barOperate">
    <!--<a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>-->
    <a class="layui-btn layui-btn-xs" permission:hasPermission="role::update" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" permission:hasPermission="role::delete" lay-event="del">删除</a>
</script>

<div id="showForm" class="hide">
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="id" value=""/>
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>角色名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="remark" class="layui-form-label">
                    角色描述
                </label>
                <div class="layui-input-inline">
                    <textarea  id="remark" name="remark"
                               autocomplete="off" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item" id="permissionView">

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button  class="layui-btn save-update-button" lay-filter="add" lay-submit="">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>
<!--权限模板-->
<script id="permissionTpl" type="text/html">
    <label class="layui-form-label">{{ d.title }}</label>
    <div class="layui-input-block">
        {{#  layui.each(d.list, function(index, item){ }}
            {{# if(item.checked && d.checked ){ }}

                 {{# if(item.pid==null || item.pid==''){ }}
                 {{# if(index!=0){ }}
                 <br>
                 {{# } }}
                 <input type="checkbox" class="permission-parent"  lay-filter="permission" keyId="{{ item.id}}" module="{{ item.module }}" privilege="{{ item.privilege }}" pid="{{ item.pid }}" name="permissionId[{{ item.id }}]" value="{{ item.id }}" lay-skin="primary" title="{{ item.name }}"   checked="checked" ><br>
                 {{# }else{ }}
                 <input type="checkbox"  lay-filter="permission" keyId="{{ item.id}}"   module="{{ item.module }}" privilege="{{ item.privilege }}" pid="{{ item.pid }}"  name="permissionId[{{ item.id }}]" value="{{ item.id }}" lay-skin="primary" title="{{ item.name }}"  checked="checked" >
                 {{# } }}

            {{# }else{ }}

                 {{# if(item.pid==null || item.pid==''){ }}
                 {{# if(index!=0){ }}
                 <br>
                 {{# } }}
                 <input type="checkbox"  class="permission-parent"  lay-filter="permission" keyId="{{ item.id}}" module="{{ item.module }}" privilege="{{ item.privilege }}" pid="{{ item.pid }}" name="permissionId[{{ item.id }}]" value="{{ item.id }}" lay-skin="primary" title="{{ item.name }}"  ><br>
                 {{# }else{ }}
                 <input type="checkbox"  lay-filter="permission" keyId="{{ item.id}}"  module="{{ item.module }}" privilege="{{ item.privilege }}" pid="{{ item.pid }}" name="permissionId[{{ item.id }}]" value="{{ item.id }}" lay-skin="primary" title="{{ item.name }}"  >
                 {{# } }}

            {{# } }}
        {{#  }); }}
        {{#  if(d.list.length === 0){ }}
        无数据
        {{#  } }}
    </div>
</script>


<script th:src="@{/js/system/role/role.js}"></script>
</body>
</html>